<?php

namespace app\admin\validate;

use think\Validate;

class Caches extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */
    protected $message = [];

    protected $scene = [];

    public function __construct()
    {
        $this->batch();
        $this->rule = [

            'media_title'                   => 'require',
            'media_category_id'             => 'require|integer',
            //'meida_img'                     => 'require',
            'media_order'                   => 'require|integer',
            'media_recom'                   => 'require|integer',
            'media_model_id'                => 'require|integer',
            'media_member_id'               => 'require|integer',
            'media_content'                 => 'require',
            'media_desc'                    => 'require',

            //fwf_config
            'config_pid'                    => 'require|integer',
            'config_name'                   => 'require',
            'config_url'                    => ['require','regex'=>'/^[A-Z_a-z][A-Z_a-z0-9\/]*/'],
            'config_order'                  => 'integer',
            'config_status'                 => 'require|integer',

            //fwf_cache
            'cache_pid'                     => 'require|integer',
            'cache_menu_id'                 => 'require|integer',
            'cache_name'                    => 'require',

        ];
        $this->message = [
            'cate_type.require'             => lang('cate_type').lang('require'),
            'cate_type.integer'             => lang('cate_type').lang('need_int'),
            'cate_order.integer'            => lang('cate_order').lang('need_int'),
            'cate_order.require'            => lang('cate_order').lang('require'),
            'cate_name.require'             => lang('cate_order').lang('require'),

            'config_pid.require'            => lang('config_pid').lang('require'),
            'config_pid.integer'            => lang('config_pid').lang('need_int'),
            'config_name.require'           => lang('config_name').lang('require'),
            'config_url.require'            => lang('config_url').lang('require'),
            'config_url.regex'              => lang('config_url').'格式不正确',
            'config_order.integer'          => lang('config_order').lang('need_int'),
            'config_order.require'          => lang('config_order').lang('require'),

            'cache_pid.require'             => lang('cache_pid').lang('require'),
            'cache_pid.integer'             => lang('cache_pid').lang('need_int'),
            'cache_menu_id.require'         => lang('cache_menu_id').lang('require'),
            'cache_menu_id.integer'         => lang('cache_menu_id').lang('need_int'),
            'cache_name.require'            => lang('cache_name').lang('require'),
        ];
        $this->scene = [

            'cache_save'                    =>['cache_pid','cache_menu_id','cache_name'],
        ];

    }
}
